﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace форматирование_диска
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            

        }

        private void button1_Click(object sender, EventArgs e)
        {
            StartFormat();
        }

        private void StartFormat()
        {
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            int incriment = new Random().Next(5);
            if (incriment + progressBar1.Value <= progressBar1.Maximum)
            {
                progressBar1.Value += incriment;
            }
            else
            {
                timer1.Stop();

                MessageBox.Show( "Форматирование диска успешно завершено");
            }

        }

        private void button2_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Отмена невозможна.");
            StartFormat();
        }
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            e.Cancel = true;
        }

   
    }
}
